﻿using MediatR;
using Production_Get.API.Infrastructures.Interfaces;
using Return.Enum;
using THE_WIND_RISES.Common.Domans.BasicInformation.Materials;
using THE_WIND_RISES.Common.Dtos;

namespace Production_Get.API.Application.MaterialManagement
{
    public class SpecsUnitSeachHandler : IRequestHandler<SpecsUnitSeachCommon, Result>
    {
        private readonly IBaseRepositoryGet<SpecsUnit> SpecsUnitRepository;
        public SpecsUnitSeachHandler(IBaseRepositoryGet<SpecsUnit> specsUnitRepository)
        {
            SpecsUnitRepository = specsUnitRepository;
        }
        public async Task<Result> Handle(SpecsUnitSeachCommon request, CancellationToken cancellationToken)
        {
            var result = new Result() { Code = (int)CommonErrorCodes.Search };
            string sql = "SELECT * FROM SpecsUnit";
            var list = SpecsUnitRepository.GetAll(sql, default).ToList();
            if (list != null)
            {
                result.Code = (int)CommonErrorCodes.Success;
                result.Data = list;
                result.Msg = "显示成功";
            }

            return result;
        }
    }
}
